let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n68,
  i =
    (this && this.__extends) ||
    ((_n68 = function n(t, e) {
      return (_n68 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
      function (t, e) {
        function o() {
          this.constructor = t;
        }
        _n68(t, e),
          (t.prototype =
            null === e
              ? Object.create(e)
              : ((o.prototype = e.prototype), new o()));
      }),
  r =
    (this && this.__decorate) ||
    function (t, e, o, n) {
      var i,
        r = arguments.length,
        a =
          r < 3
            ? e
            : null === n
              ? (n = Object.getOwnPropertyDescriptor(e, o))
              : n;
      if (
        'object' ==
        (typeof Reflect === 'undefined' ? 'undefined' : typeof Reflect) &&
        'function' == typeof Reflect.decorate
      )
        a = Reflect.decorate(t, e, o, n);
      else
        for (var s = t.length - 1; s >= 0; s--) {
          (i = t[s]) &&
            (a = (r < 3 ? i(a) : r > 3 ? i(e, o, a) : i(e, o)) || a);
        }
      return r > 3 && a && Object.defineProperty(e, o, a), a;
    };
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.CardUpgradePanel = void 0);
var a = t('UIPanel'),
  s = t('UIViewRes'),
  c = t('UILayer'),
  l = t('ComUtils'),
  u = t('SoundMrg'),
  h = t('AbsInfo'),
  p = t('BagMrg'),
  f = t('ResMrg'),
  d = t('BattleUtils'),
  g = t('GeneralTips'),
  _ = t('CardCfg'),
  y = t('CardMrg'),
  C = t('ItemCfg'),
  m = t('PlayerMrg'),
  v = t('LangCfg'),
  b = cc._decorator,
  M = b.ccclass,
  I =
    (b.property,
      (function (t) {
        function e() {
          return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
          i(e, t),
          (e.prototype.onInit = function () {
            t.prototype.onInit.call(this),
              l.default
                .getNode(this.view, 'root/btnClose')
                .on(cc.Node.EventType.TOUCH_END, this.onTouchCloseHandler, this),
              (this._anim = this.view.getComponent(cc.Animation)),
              (this._expend = l.default.getNode(this.view, 'root/bottom/expend')),
              (this._30mihuangdiban = l.default.getNode(
                this.view,
                'root/30mibaidiban/30mihuangdiban'
              )),
              (this._txtWeiHuoDe = l.default.getNode(
                this.view,
                'root/top/item/imgCard/txtWeiHuoDe'
              )),
              (this._imgFrame = l.default.getComponent(
                cc.Sprite,
                this.view,
                'root/top/item/imgCard'
              )),
              (this._imgIcon = l.default.getComponent(
                cc.Sprite,
                this.view,
                'root/top/item/imgCard/imgIcon'
              )),
              (this._imgQuality = l.default.getComponent(
                cc.Sprite,
                this.view,
                'root/top/item/imgCard/imgQuality'
              )),
              (this._imgDebris = l.default.getComponent(
                cc.Sprite,
                this.view,
                'root/bottom/expend/imgDebris'
              )),
              (this._txtLevel = l.default.getComponent(
                cc.Label,
                this.view,
                'root/top/item/imgCard/txtLevel'
              )),
              (this._txtName = l.default.getComponent(
                cc.Label,
                this.view,
                'root/top/item/imgCard/txtName'
              )),
              (this._txtCount = l.default.getComponent(
                cc.Label,
                this.view,
                'root/bottom/expend/txtCount'
              )),
              (this._txtCurDesc = l.default.getComponent(
                cc.RichText,
                this.view,
                'root/top/desc/txtCurDesc'
              )),
              (this._txtNextDesc = l.default.getComponent(
                cc.RichText,
                this.view,
                'root/30mibaidiban/30mihuangdiban/layout/txtNextDesc'
              )),
              (this._btnUpgrade = l.default.getComponent(
                cc.Button,
                this.view,
                'root/bottom/btnUpgrade'
              )),
              (this._btnBattle = l.default.getComponent(
                cc.Button,
                this.view,
                'root/bottom/btnBattle'
              )),
              (this._btnRemove = l.default.getComponent(
                cc.Button,
                this.view,
                'root/bottom/btnRemove'
              )),
              this._btnUpgrade.node.on(
                cc.Node.EventType.TOUCH_END,
                this.onTouchUpgradeHandler,
                this
              ),
              this._btnBattle.node.on(
                cc.Node.EventType.TOUCH_END,
                this.onTouchBattleHandler,
                this
              ),
              this._btnRemove.node.on(
                cc.Node.EventType.TOUCH_END,
                this.onTouchRemoveHandler,
                this
              );
          }),
          (e.prototype.onLang = function () {
            var t = l.default.getComponent(
              cc.Label,
              this.view,
              'root/top/desc/txtCurTitle'
            );
            (t.string = v.LangCfg.ins.getContent(200800)),
              ((t = l.default.getComponent(
                cc.Label,
                this.view,
                'root/30mibaidiban/30mihuangdiban/layout/txtNextTtile'
              )).string = v.LangCfg.ins.getContent(200801)),
              ((t = l.default.getComponent(
                cc.Label,
                this.view,
                'root/bottom/btnBattle/Background/txtLabel'
              )).string = v.LangCfg.ins.getContent(200802)),
              ((t = l.default.getComponent(
                cc.Label,
                this.view,
                'root/bottom/btnRemove/Background/txtLabel'
              )).string = v.LangCfg.ins.getContent(200803)),
              ((t = l.default.getComponent(
                cc.Label,
                this.view,
                'root/top/item/imgCard/txtWeiHuoDe'
              )).string = v.LangCfg.ins.getContent(200702)),
              ((t = l.default.getComponent(
                cc.Label,
                this.view,
                'root/bottom/btnUpgrade/Background/txtLabel'
              )).string = v.LangCfg.ins.getContent(1018));
          }),
          Object.defineProperty(e.prototype, 'btnUpgrade', {
            get: function get() {
              return this._btnUpgrade.node;
            },
            enumerable: !1,
            configurable: !0
          }),
          Object.defineProperty(e.prototype, 'btnClose', {
            get: function get() {
              return l.default.getNode(this.view, 'root/btnClose');
            },
            enumerable: !1,
            configurable: !0
          }),
          (e.prototype.onShow = function () {
            t.prototype.onShow.call(this),
              this._anim.play('DefShowView'),
              (this._info = this.getData()),
              this._info.on(
                h.InfoEvent.LevelChanged,
                this.onLevelChangedHandler,
                this
              ),
              this.refreshCard(),
              this.onLevelChangedHandler();
          }),
          (e.prototype.onClose = function () {
            t.prototype.onClose.call(this),
              this._info.off(
                h.InfoEvent.LevelChanged,
                this.onLevelChangedHandler,
                this
              );
          }),
          (e.prototype.refreshCard = function () {
            var t = C.ItemCfg.ins.getData(this._info.itemId),
              e = this._txtName.node.getComponent(cc.LabelOutline);
            f.ResMrg.loadSpriteByAtlas(
              this._imgFrame,
              'Atlas/Card',
              'frame' + this._info.quality
            ),
              f.ResMrg.loadSpriteByAtlas(
                this._imgIcon,
                'Atlas/Card',
                this._info.icon
              ),
              f.ResMrg.loadSpriteByAtlas(
                this._imgQuality,
                'Atlas/Card',
                'quality' + this._info.quality
              ),
              f.ResMrg.loadSpriteByAtlas(this._imgDebris, 'Atlas/Item', t.icon),
              (this._txtName.string = v.LangCfg.ins.getContent(this._info.name)),
              (e.color = cc.Color.fromHEX(
                e.color,
                d.default.CardNameOutLineColors[this._info.quality]
              )),
              this.refreshOther();
          }),
          (e.prototype.refreshOther = function () {
            var t = p.BagMrg.ins.getCount(this._info.itemId);
            (this._txtCount.string =
              Math.min(t, this._info.itemCount) + '/' + this._info.itemCount),
              (this._txtLevel.string = 'Lv.' + this._info.level),
              (this._txtCurDesc.string = d.default.getCardDesc(this._info.data)),
              t >= this._info.itemCount
                ? (this._txtCount.node.color = cc.Color.fromHEX(
                  this._txtCount.node.color,
                  '#309D01'
                ))
                : (this._txtCount.node.color = cc.Color.fromHEX(
                  this._txtCount.node.color,
                  '#C61300'
                ));
          }),
          (e.prototype.onLevelChangedHandler = function () {
            var t = this.view.getChildByName('root'),
              e = t.getChildByName('bottom');
            this._info.own
              ? (this.refreshOther(),
                (this._txtNextDesc.string = d.default.getCardDesc(
                  _.CardCfg.ins.getCardByLevel(
                    this._info.cardId,
                    this._info.level + 1
                  )
                )),
                this._info.isMaxLevel
                  ? ((this._expend.active = !1),
                    (this._30mihuangdiban.active = !1),
                    (this._btnUpgrade.node.active = !1),
                    (this._btnBattle.node.x = 0),
                    (this._btnRemove.node.x = 0),
                    cc
                      .tween(t)
                      .to(0.1, {
                        height: 430
                      })
                      .start())
                  : ((this._expend.active = !0),
                    (this._30mihuangdiban.active = !0),
                    (this._btnUpgrade.node.active = !0),
                    (this._btnBattle.node.x = -this._btnUpgrade.node.x),
                    (this._btnRemove.node.x = -this._btnUpgrade.node.x),
                    cc
                      .tween(t)
                      .to(0.1, {
                        height: 700
                      })
                      .start()),
                (this._btnBattle.node.active = !this._info.isBattle),
                (this._btnRemove.node.active = this._info.isBattle),
                (e.active = !0),
                (this._txtWeiHuoDe.active = !1),
                l.default.setGray(this._imgFrame.node, !1))
              : ((this._expend.active = !1),
                (this._30mihuangdiban.active = !1),
                (e.active = !1),
                (this._txtLevel.string = ''),
                (this._txtWeiHuoDe.active = !0),
                cc
                  .tween(t)
                  .to(0.1, {
                    height: 335
                  })
                  .start(),
                l.default.setGray(this._imgFrame.node, !0));
          }),
          (e.prototype.onTouchUpgradeHandler = function () {
            // 检查卡片信息是否存在
            if (this._info) {
              // 检查卡片是否达到最大等级
              const isMaxLevel = this._info.isMaxLevel;
              // 获取玩家拥有的材料数量
              const itemCount = p.BagMrg.ins.getCount(this._info.itemId);
              // 检查材料数量是否足够
              const hasEnoughItems = this._info.itemCount <= itemCount;

              if (!isMaxLevel && hasEnoughItems) {
                // 材料足够且未达到最大等级，进行升级
                this._info.upgrade();
              } else {
                // 显示升级失败提示
                g.GeneralTips.show(v.LangCfg.ins.getContent(1004));
              }
            }

            // 检查并显示引导
            if (m.PlayerMrg.ins.hasGuide(6)) {
              m.PlayerMrg.ins.showGuide(6);
            }
            // 播放点击音效
            u.SoundMrg.click();
          }),
          (e.prototype.onTouchBattleHandler = function () {
            u.SoundMrg.click(),
              this._info.isBattle ||
              (y.CardMrg.ins.execute(this._info, !0)
                ? ((this._btnBattle.node.active = !1),
                  (this._btnRemove.node.active = !0),
                  g.GeneralTips.show(v.LangCfg.ins.getContent(1008)))
                : g.GeneralTips.show(v.LangCfg.ins.getContent(1010)));
          }),
          (e.prototype.onTouchRemoveHandler = function () {
            u.SoundMrg.click(),
              this._info.isBattle &&
              y.CardMrg.ins.execute(this._info, !1) &&
              ((this._btnBattle.node.active = !0),
                (this._btnRemove.node.active = !1),
                g.GeneralTips.show(v.LangCfg.ins.getContent(1009)));
          }),
          (e.RES = new s.UIViewRes(
            'CardUpgradeView',
            'Main',
            c.UILayer.PopLayer
          )),
          r([M('CardUpgradePanel')], e)
        );
      })(a.default));
(o.CardUpgradePanel = I), console.log('end');
module.exports = e.exports;
